From: Christian Korber Date: Mon, 7 Jul 2025 07:08:10 +0000 (+0200) Subject: luci-app-snmpd: add Trap Settings X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=b232a6d76b322b621b0add88e2b29e41c871ca22;p=project%2Fluci.git luci-app-snmpd: add Trap Settings This commit adds the possibility to add traps to the configuration. Signed-off-by: Christian Korber --- diff --git a/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js b/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js index 858a9056d6..4d1b422645 100644 --- a/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js +++ b/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js @@ -227,6 +227,55 @@ return L.view.extend({ this.oid.depends('RestrictOID', 'yes'); }, + populateTrapsSettings: function(subsection, desc, s, type) { + let g, go, o; + + o = s.taboption('traps', form.SectionValue, '__traps__', + form.GridSection, subsection, null, desc); + + g = o.subsection; + g.anonymous = true; + g.addremove = true; + g.nodescriptions = true; + g.modaltitle = desc; + + go = g.option(form.Value, + type, + _(type)); + if (type == 'HostIP'){ + go.datatype = 'ipaddr'; + }else{ + go.datatype = 'hostname'; + } + go.optional = false; + go.rmempty = false; + + go = g.option(form.Value, + 'Port', + _('Port')); + go.datatype = 'port' + go.default = '162' + go.optional = true; + go.rmempty = false; + + go = g.option(form.Value, + 'Community', + _('Community')); + go.datatype = 'string'; + go.optional = false; + go.rmempty = false; + + go = g.option(form.ListValue, + 'Type', + _('Type')); + go.value('trapsink', _('SNMPv1 Trap Receiver')); + go.value('trap2sink', _('SNMPv2c Trap Receiver')); + go.value('informsink', _('SNMPv2c Inform Receiver')); + go.default = 'trapsink'; + go.optional = false; + go.rmempty = false; + }, + render: function(data) { let m, s, o, g, go; @@ -374,6 +423,12 @@ return L.view.extend({ s.tab('v3', _('SNMPv3')); this.populateV3Settings('v3', s); + s.tab('traps', _('Traps', 'SNMP')); + this.populateTrapsSettings('trap_HostName', 'Traps via Hostname', + s, 'HostName'); + this.populateTrapsSettings('trap_HostIP', 'Traps via IP-Address', + s, 'HostIP'); + return m.render(); },